package com.rgs.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.rgs.ssm.dao.IProductDao;
import com.rgs.ssm.domain.Product;
import com.rgs.ssm.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @create 2021-02-15 16:51
 **/

@Service
@Transactional
public class ProductService implements IProductService {

    @Autowired
    private IProductDao productDao;

    @Override
    public void saveProduct(Product product) {
        productDao.saveProduct(product);
    }

    @Override
    public void delete(Integer id) {
        productDao.delete(id);
    }

    @Override
    public void update(Product product) {
        productDao.update(product);
    }

    @Override
    public List<Product> findAll(int page,int size){
        PageHelper.startPage(page,size);
        return productDao.findAll();
    }

    public List<Product> findAll(){
        return productDao.findAll();
    }

    @Override
    public Product findById(Integer id) {
        return productDao.findById(id);
    }

}
